package streaming.api.source;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import utils.PropertiesReader;

/**
 * 从文件file读取数据(单个文件)
 * env.readTextFile
 */
public class Source2_readTextFile {

    private static String filePath = PropertiesReader.get("default.file.from.path");

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        // 从文件读数据
        DataStream dataStream = env.readTextFile(filePath);
        //打印输出
        dataStream.print("data:");
        //执行
        env.execute();
    }

}
